<template>

  <el-row class="mb-4">
    <el-button>Default</el-button>
    <el-button type="primary">Primary</el-button>
    <el-button type="success">Success</el-button>
    <el-button type="info">Info</el-button>
    <el-button type="warning">Warning</el-button>
    <el-button type="danger">Danger</el-button>
  </el-row>

  <el-select v-model="value" class="m-2" placeholder="Select" size="large">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>

	首页
  <p v-for="(item,index) in dataList" :key="index">{{ item.title }}</p>

  state
  <p v-for="(item,index) in state.dataList" :key="index">{{ item.title }}</p>


  <p>count*2 = {{ dbcount }}</p>


  <el-button @click="count++">{{ 'count: +' + count }}</el-button>

  
</template>

<script lang="ts" setup>
import { processData } from '@/api/index';
import { ref,reactive, onMounted,computed } from 'vue';
let value = ref('');
let count = ref(1);
let dataList = reactive([] as any[]);//定义数组
let state = reactive<any>(source()); //定义变量
let type = ref<string>('todo') //定义变量


const options = [
  {
    value: 'Option1',
    label: 'Option1',
  },
  {
    value: 'Option2',
    label: 'Option2',
  },
  {
    value: 'Option3',
    label: 'Option3',
  },
  {
    value: 'Option4',
    label: 'Option4',
  },
  {
    value: 'Option5',
    label: 'Option5',
  },
]

//计算属性
let dbcount = computed(()=>{
  let num = 2*count.value;   
  return num;
})


function source(){
  return{
    dataList:[]
  }
}


onMounted(()=>{
  //初始化待办数据
  initProcessData();
  initStateData();
})

//获取待办数据1
const initProcessData = async() =>{
  dataList.length = 0; //清空数组
  const res = await processData({boxName:type.value});
  if(res.data && res.data.length > 0 && res.data[0].sumData != 0){
    const bpmTodoSum = res.data[res.data.length-1].sumData;
    for(let i:number = 0;i < 6; i++){
      if(Array.isArray(res.data[i])){						
        dataList.push(res.data[i][0]);
      }						
    }
  }
}

//获取待办数据2
const initStateData = async() =>{
  state.dataList = []; //清空数组
  const res = await processData({boxName:type.value});
  if(res.data && res.data.length > 0 && res.data[0].sumData != 0){
    const bpmTodoSum = res.data[res.data.length-1].sumData;
    for(let i:number = 0;i < 6; i++){
      if(Array.isArray(res.data[i])){						
        state.dataList.push(res.data[i][0]);
      }						
    }
  }
}



</script>

<style>
</style>
